package com.flca.frw.util
{
	import mx.utils.StringUtil;
	
	public class StringUtils
	{
		public static function formatString(value:String) : String 
		{
			var result:String  = "";
			var arr:Array = value.split(" ");
			for each(var s:String in arr) {
				s = StringUtil.trim(s);
				if (s != "null") {
					result = result + s + " ";
				}
			}
			return result;
		}
		
        public static function replace (s : String, arg_search : String, arg_replace : String) : String
        {
                var string:String = s;
                var position: int;
                var endText:String = "";
                var preText:String  = "";
                var newText:String  = "";
                if (arg_search.length == 1)
                {
                        return string.split (arg_search).join (arg_replace);
                }
                position = string.indexOf (arg_search);
                if (position == - 1)
                {
                        return string;
                }
                endText = string;
                do
                {
                        position = endText.indexOf (arg_search);
                        preText = endText.substring (0, position);
                        endText = endText.substring (position + arg_search.length);
                        newText += preText + arg_replace;
                } while (endText.indexOf (arg_search) != - 1);
                newText += endText;
                return newText;
        };
	
		public static function isEmpty(value:String) : Boolean {
			return value == null || value == "";
		}
	}
}